#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2018/4/11 17:27
# @Author  : simple0426
# @Email   : istyle.simple@gmail.com
# @File    : paramiko_demo.py
# @Software: PyCharm

import paramiko

# scp范例
# t = paramiko.Transport(('10.10.10.243', 22))
# t.connect(username='dell', password='123456789')
# sftp = paramiko.SFTPClient.from_transport(t)
# sftp.mkdir('test12')
# sftp.put('paramiko_demo.py', 'paramiko_demo.py')
# sftp.get('nginx/Vagrantfile', 'Vagrantfile.rb')
# t.close()

# ssh范例
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='10.10.10.243', username='dell', password='123456789')
stdin, stdout, stderr = ssh.exec_command('free -m')
for line in stdout.readlines():
        print(line)
# print(stdout.readlines())
ssh.close()

